#include "stdafx.h"
#include "Camera.h"

void Camera::AddPos(sint dx, sint dy)
{
	m_x += dx;
	m_y += dy;

	Resize();
}

void Camera::Resize()
{
	if ( m_x < 0 + GameConfig::Get().MapViewSizeW / 2 ) m_x = 0 + GameConfig::Get().MapViewSizeW / 2;
	if ( m_y < 0 + GameConfig::Get().MapViewSizeH / 2 ) m_y = 0 + GameConfig::Get().MapViewSizeH / 2;

	if ( m_x >= GameConfig::Get().MapSize - GameConfig::Get().MapViewSizeW / 2 ) m_x = GameConfig::Get().MapSize - 1 - GameConfig::Get().MapViewSizeW / 2;
	if ( m_y >= GameConfig::Get().MapSize - GameConfig::Get().MapViewSizeH / 2 ) m_y = GameConfig::Get().MapSize - 1 - GameConfig::Get().MapViewSizeH / 2;
}

void Camera::SelectZ(sint i)
{
	m_z += i;
	if ( m_z < 0 )
		m_z = 0;
	else if ( m_z >= (GameConfig::Get().MapZ - 1) )
		m_z = GameConfig::Get().MapZ - 1;
}
